<?php

defined('BY_JYA') or exit('error');
$cashierid=$this->checklogin();
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
if($_RQ['op']=='list'){
	$pindex = max(1, intval($_SESSION['page']));
	$psize = 10;
	$params=array('uniacid'=>$_SESSION['uniacid'],'cashierid'=>$cashierid);
   // $fields=array('id','catename','status','displayorder');
    $orderby='id desc';
	$total='';
	$return['list']=pdo_getslice('jy_merch_cashier_pay_log',$params,array($pindex,$psize),$total,$fields,'',$orderby);
	$return['status']=array('0'=>'未支付','1'=>'已支付');
	$return['paytype']=array('0'=>'微信支付','1'=>'现金支付');
	foreach($return['list'] as &$v){
		$v['member']=cfc('core')->member_show($v['mid']);
		$o=pdo_get('jy_merch_cashier_order',array('uniacid'=>$_SESSION['uniacid'],'id'=>$v['orderid']));
		$v['ordersn']=$o['ordersn'];
		$v['status']=$o['status'];		
		$v['createtime']=date('Y-m-d H:i:s',$o['createtime']);		
	}
	$htmls=array(
		'type'=>'list',
		'tabs'=>array(
			array('op'=>'list','title'=>'订单列表'),			
		),
		'list'=>array('data'=>'list','edit'=>false,'list'=>array(
			array('name'=>'member','title'=>'会员信息','type'=>'member'),
			array('name'=>'status','title'=>'状态','type'=>'radio','options'=>'status'),	
			array('name'=>'ordersn','title'=>'订单号','type'=>'string'),
			array('name'=>'createtime','title'=>'日期','type'=>'string'),
			array('name'=>'paytype','title'=>'支付方式','type'=>'radio','options'=>'paytype'),	
			array('name'=>'money','title'=>'金额','type'=>'string'),					
		)),
	);
	$return['htmls']=$htmls;	
	exi($return);
}
if($_RQ['op']=='del'){
	$id=intval($_RQ['id']);
	if($id){
		pdo_delete('jy_merch_cashier_pay_log',array('id'=>$id,'uniacid'=>$_SESSION['uniacid']));	
	}
	$del=trim($_RQ['del'],';');
	if($del){
		$del=explode(';',$del);
		foreach($del as $id){
			$id=intval($id);
			if($id){
				pdo_delete('jy_merch_cashier_pay_log',array('id'=>$id,'uniacid'=>$_SESSION['uniacid']));
			}
		}
	}
	exi('删除成功！','','edit');
}
